#include <graphics.h>
#define centerX 300
#define centerY 300
#define radius 200
#include <math.h>
#include <time.h>
#define windwidth 	360		//宽度
#define windhigh  	360		//高度
#define T 120
#define pai 3.1415926	
using namespace std;

int main (){
	initgraph(600,600);
	setbkcolor(WHITE);
		ege_enable_aa(true);					//开启抗锯齿
setcolor(EGERGB(0, 0, 0));
setfillcolor(EGERGB(0, 0, 0));  // 设置填充颜色
sector(centerX, centerY, 0, 360, radius+25 , radius+25);  // 外圆

setcolor(EGERGB(61, 58,55));
setfillcolor(EGERGB(61, 58,55));  // 设置填充颜色
sector(centerX, centerY, 0, 360, radius+20 , radius+20);  // 外圆

setcolor(EGERGB(20, 20,20));
setfillcolor(EGERGB(20, 20,20));  // 设置填充颜色
sector(centerX, centerY, 0, 360, radius+9 , radius+9);  // 外圆

setcolor(EGERGB(50, 50,50));
setfillcolor(EGERGB(50, 50,50));  // 设置填充颜色
sector(centerX, centerY, 0, 360, radius+7 , radius+7);  // 外圆

setcolor(EGERGB(10, 10,10));
setfillcolor(EGERGB(10, 10,10));  // 设置填充颜色
sector(centerX, centerY, 0, 360, radius+1 , radius+1);  // 外圆
	void xx();
	xx();
	void drawScrew(float x, float y, float r);
	drawScrew(300,300,230);
	
	getch();
	closegraph();
	
}
//画刻度
void xx(){
	for(int i=0;i<360;i+=1){		
//用循环画刻度
		double x1=T+cos(pai/180*i)*windhigh/2+windwidth/2,y1=T+sin(pai/180*i)*windhigh/2+windhigh/2;//刻度起点
		double x2=T+cos(pai/180*i)*(windhigh/2-10)+windwidth/2,y2=T+sin(pai/180*i)*(windhigh/2-10)+windhigh/2;//刻度终点
		
		if(i==10||i==30||i==50||i==70||i==90||i==110||i==130||i==155||i==180||i==205||i==230||i==250||i==270||i==290||i==310||i==330||i==350){												//角度能被30整除为整点
			setcolor(EGEARGB(0xFF, 255, 255, 255)); 
			setlinewidth(4);	//整点刻度加粗
			x2=T+cos(pai/180*i)*(windhigh/2-40)+windwidth/2;
			y2=T+sin(pai/180*i)*(windhigh/2-40)+windhigh/2;//刻度线加长
			setfont(50, 0, "SimHei");           // 黑体				//设置100字号和字型
			setbkmode(TRANSPARENT);
			if(i==50){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2-10,y2-20,"4");
			}
			
			if(i==90){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2-10,y2-20,"2");}
			
			
			if(i==130){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2,y2,"1");}
			if(i==155){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2,y2,"5");}
			if(i==180){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2,y2,"0");}
			if(i==205){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2,y2,"5");}
			if(i==230){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2,y2,"1");}
			
			if(i==270){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2-10,y2+20,"2");}
			
			if(i==310){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2-20,y2+10,"4");}
			if(i==350){
				settextjustify(LEFT_TEXT,CENTER_TEXT);
				xyprintf(x2-15,y2+20,"6");}
		}
		else{
			setlinewidth(2);
			if(i>130&&i<230&&(i-130)%5==0){
				x1=T+cos(pai/180*i)*windhigh/2+windwidth/2,y1=T+sin(pai/180*i)*windhigh/2+windhigh/2;//刻度起点
				x2=T+cos(pai/180*i)*(windhigh/2-25)+windwidth/2,y2=T+sin(pai/180*i)*(windhigh/2-25)+windhigh/2;//刻度终点
			}
			else if(i>10&&i<90&&(i-10)%10==0){
				x1=T+cos(pai/180*i)*windhigh/2+windwidth/2,y1=T+sin(pai/180*i)*windhigh/2+windhigh/2;//刻度起点
				x2=T+cos(pai/180*i)*(windhigh/2-25)+windwidth/2,y2=T+sin(pai/180*i)*(windhigh/2-25)+windhigh/2;//刻度终点
			}
			else if(i>270&&i<350&&(i-270)%10==0){
				x1=T+cos(pai/180*i)*windhigh/2+windwidth/2,y1=T+sin(pai/180*i)*windhigh/2+windhigh/2;//刻度起点
				x2=T+cos(pai/180*i)*(windhigh/2-25)+windwidth/2,y2=T+sin(pai/180*i)*(windhigh/2-25)+windhigh/2;//刻度终点
			}
			else{
				continue;
			}
		}
		setcolor(EGEARGB(0xFF, 255, 255, 255)); 			//设置刻度线的颜色
		ege_line(x1,y1,x2,y2);			//画刻度线
	}
	setlinewidth(4);
	ege_arc(150,150,300,300,350,20);
	setlinewidth(4);
	ege_arc(160,150,300,300,170,20);
	setlinewidth(7);
	ege_line(300,300,170,300);
	setfont(15, 0, "SimHei");           // 黑体				//设置100字号和字型
	xyprintf(240,250,"THDS FT PER MIN");
	// 绘制黑色实心基底圆
	setcolor(BLACK);
	setfillcolor(EGERGB(30, 30,30));
	fillcircle(300, 300, 20); // 圆心(320,240)，半径100
	setlinewidth(7);
	ege_line(290,300,280,300);
	
}
//画螺丝
void drawScrew(float x, float y, float r)
{
	float dx[5] = {30-r,r-30,30-r,r-30};
	float dy[5] = {30-r,r-30,r-30,30-r};
	setfillcolor(EGERGB(170,170,170));
	for(int i=0;i<4;++i)
	{
		dx[i] += x;
		dy[i] += y;
		ege_fillcircle(dx[i],dy[i],20.0);
		setcolor(BLACK);
		setlinestyle(SOLID_LINE,0,3);
		ege_line(dx[i]-8,dy[i],dx[i]+8,dy[i]);
		ege_line(dx[i],dy[i]-8,dx[i],dy[i]+8);        
	}
}
